from pylab import *
from time import time
from fs import fs
import numpy as np
import mpl_toolkits.mplot3d.axes3d as p3
NI = 2
NS = 40
RLB = 20
SZ = 30
c = fs()
c.parameters.read_file("../../param/stofac.prm")
c.gen_inst(NI = NI, NS = NS, RLB = RLB, seed = 100)

Z = np.zeros((SZ, SZ))
c.solve()
print c.solution.get_objective_value()
print c.solution.get_values()
print c.variables.get_names()
#c.set_problem_type(c.problem_type.LP)
print "------------------"
for i in range(SZ):
    for j in range(SZ):
        c.set_bigm(rank = [i+1,j+1])
        c.solve()
        Z[i,j] = c.solution.get_objective_value()
        print [i,j], c.solution.get_values(['x_0','x_1'])
#X_cor = [c.dm_diff_lists[0][i] for i in range(SZ)]
#Y_cor = [c.dm_diff_lists[1][i] for i in range(SZ)]
X_cor = range(SZ)
Y_cor = range(SZ)
X,Y = meshgrid(X_cor, Y_cor)
fig=figure()
ax = p3.Axes3D(fig)
ax.plot_wireframe(X,Y,Z)
print X
print Y
print Z
ax.set_xlabel('M(1) rank')
ax.set_ylabel('M(2) rank')
ax.set_zlabel('Optimal cost')
show()

